﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Uc_staff_online.ascx.vb" Inherits="Apps_Shares_Uc_staff_online" %>
<%--==============================BEGIN Gridview==============================--%>
<asp:ListView ID="gvDisplay" runat="server" DataSourceID="gvDisplaysrc">
    <ItemTemplate>
        <tr>
            <td align="center" class="td_data" bordercolor="#CCCCCC"><asp:CheckBox ID="staff_no_check" runat="server" />&nbsp;</td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <asp:Label ID="staff_no_label" runat="server" Text='<%# Eval("staff_no") %>' />
                <asp:Label ID="staff_online_id_label" runat="server" Text='<%# Eval("staff_online_id") %>' Visible="false" />
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <asp:Label ID="staff_name_label" runat="server" 
                    Text='<%# Eval("staff_name") %>' />
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <asp:Label ID="department_name_label" runat="server" 
                    Text='<%# Eval("department_name") %>' />
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <asp:Label ID="Label2" runat="server" 
                    Text='<%# Eval("last_update_datetime") %>' />
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <asp:Label ID="Label3" runat="server" 
                    Text='<%# Eval("ip_address") %>' />
            </td>
        </tr>
    </ItemTemplate>
    <EmptyDataTemplate>
        <br />
        <span class='star'>
            <center>ไม่พบข้อมูล</center>
        </span>
    </EmptyDataTemplate>
    <LayoutTemplate>
        <table ID="itemPlaceholderContainer" runat="server" cellspacing="2" cellpadding="2" bordercolor="#999999" border="0" align="center" width="100%">
            <tr id="trHead" runat="server" align="center">
                <th id="Th1" runat="server" colspan="6"><asp:Label ID="Label1" runat="server" CssClass="login" Text="รายชื่อผู้ใช้งานที่ออนไลน์อยู่"/><br />&nbsp;</th>
            </tr>
            <tr runat="server" align="left">
                <th id="Th2" runat="server" colspan="6"><asp:Button ID="btnUnlockUser" runat="server" Text="บังคับออกจากระบบ" OnClick="btnUnlockUser_Click" />&nbsp;<asp:Button ID="btnRefresh" runat="server" Text="Refresh" OnClick="btnRefresh_Click" />&nbsp;<asp:Button ID='btnMainMenu' Text='<%$ Resources:Resource,BTN_MAINMENU %>' runat='server' PostBackUrl="~/Apps/ViewSystem.aspx?Edit=2" /></th>
            </tr>
            <tr id="Tr1" runat="server" bgcolor="#ff9999" align="center">
                <th id="Th3" runat="server" bgcolor="#ffffff" class="th_data" align="center">&nbsp;&nbsp;<input type="checkbox" class="check-all">&nbsp;</th>
                <th id="Th4" runat="server" bgcolor="#ffffff" class="th_data">
                    <asp:Image ID="staff_no" runat="server" Visible="false" />
                    <asp:LinkButton ID='sort2' runat='server' CommandName='Sort' CommandArgument='staff_no'>
                            เลขประจำตัว
                    </asp:LinkButton>
                </th>
                <th id="Th5" runat="server" bgcolor="#ffffff" class="th_data">
                    <asp:Image ID="staff_name" runat="server" Visible="false" />
                    <asp:LinkButton ID='sort3' runat='server' CommandName='Sort' CommandArgument='staff_name'>
                            ชื่อ - นามสกุล
                    </asp:LinkButton>
                </th>
                <th id="Th6" runat="server" bgcolor="#ffffff" class="th_data">
                    <asp:Image ID="department_name" runat="server" Visible="false" />
                    <asp:LinkButton ID='sort5' runat='server' CommandName='Sort' CommandArgument='department_name'>
                            หน่วยงานที่สังกัด
                    </asp:LinkButton>
                </th>
                <th id="Th7" runat="server" bgcolor="#ffffff" class="th_data">
                    <asp:Image ID="last_update_datetime" runat="server" Visible="false" />
                    <asp:LinkButton ID='sort6' runat='server' CommandName='Sort' CommandArgument='last_update_datetime'>
                            วันเวลาที่ออนไลน์ล่าสุด
                    </asp:LinkButton>
                </th>
                <th id="Th8" runat="server" bgcolor="#ffffff" class="th_data">
                    <asp:Image ID="ip_address" runat="server" Visible="false" />
                    <asp:LinkButton ID='sort7' runat='server' CommandName='Sort' CommandArgument='ip_address'>
                            IP Address
                    </asp:LinkButton>
                </th>
            </tr>
            <tr ID="itemPlaceholder" runat="server">
            </tr>
            <tr id="Tr2" runat="server" bgcolor="#ff9999" align="center">
                <td bgcolor="#ffffff" class="td_data_end" colspan="6">
                    <%-- ====================== Data Pager ======================--%>
                    <asp:DataPager ID="paging" runat="server" PagedControlID="gvDisplay" PageSize='10'>
                        <Fields>
                            <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="false"
                                ShowNextPageButton='false' ShowPreviousPageButton='false' FirstPageText='<<' />
                            <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                ShowNextPageButton='false' ShowPreviousPageButton='true' PreviousPageText='<' />
                            <asp:NumericPagerField />
                            <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                ShowNextPageButton='true' ShowPreviousPageButton='false' NextPageText='>' />
                            <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="true"
                                ShowNextPageButton='false' ShowPreviousPageButton='false' LastPageText='>>' />
                        </Fields>
                    </asp:DataPager>
                    <%-- ====================== Data Pager ======================--%>
                </td>
            </tr>
        </table>
    </LayoutTemplate>
</asp:ListView>
<asp:SqlDataSource ID="gvDisplaysrc" runat="server" 
    ConnectionString="<%$ ConnectionStrings:GHBankConnectionString %>" 
    SelectCommand="SELECT staff_online.staff_online_id, staff.staff_no, staff.staff_firstname + ' ' + staff.staff_lastname AS staff_name, stp_department.department_name, MAX(staff_online.last_update_datetime) AS last_update_datetime, staff_online.ip_address FROM staff INNER JOIN stp_department ON staff.department_code = stp_department.department_code INNER JOIN staff_online ON staff.staff_code = staff_online.staff_code GROUP BY staff_online.staff_online_id, staff.staff_no, staff.staff_firstname + ' ' + staff.staff_lastname, stp_department.department_name, staff_online.active, staff_online.last_update_datetime, staff_online.ip_address HAVING (staff_online.active = 1) AND (DATEDIFF(mi, staff_online.last_update_datetime, GETDATE()) < 20)"></asp:SqlDataSource>
<%--==============================END Gridview==============================--%>
<script type="text/javascript">
    $(document).ready(function() {
        // Check all checkboxes when the one in a table head is checked:
        $('.check-all').click(function() {
            $(this).parent().parent().parent().parent().find("input[type='checkbox']").attr('checked', $(this).is(':checked'));
        });
    });
</script>

